// let stock_id = args.wareHouse;
// lib.dbQueryJsonArray(`SELECT
// 	MD5(
// 		CONCAT(
// 			ip.stock_id,
// 			w.NAME,
// 			ip.item_id,
// 			p.NAME,
// 			p.sku,
// 			p.pic_url,
// 			ip.shop_id,
// 			si.shop_name,
// 			ip.fn_sku,
// 			lf.fnsku 
// 		)) id,
// 	ip.stock_id stockId,
// 	w.NAME wName,
// 	ip.item_id itemId,
// 	p.NAME pName,
// 	p.sku,
// 	p.pic_url picUrl,
// 	ip.shop_id shopId,
// 	si.shop_name sName,
// 	ip.fn_sku fnSku,
// 	lf.fnsku fnskuName,
// 	sum(
// 	IF
// 	( wb.type = 5, ip.stock_qty, 0 )) availbleNum,
// 	sum(
// 	IF
// 	( wb.type = 6, ip.stock_qty, 0 )) defectiveQuantity 
// FROM
// 	inventory_placement ip
// 	LEFT JOIN warehouse_bin wb ON wb.id = ip.bin_id
// 	LEFT JOIN warehouse w ON w.id = ip.stock_id
// 	LEFT JOIN product p ON p.id = ip.item_id
// 	LEFT JOIN shop_info si ON si.id = ip.shop_id
// 	LEFT JOIN listing_father lf ON lf.id = ip.fn_sku 
// WHERE
// 	ip.stock_id = ? 
// 	AND ip.del_flag = 0 
// 	AND wb.del_flag = 0 
// 	AND wb.type IN ( 5, 6 ) 
// GROUP BY
// 	ip.stock_id,
// 	w.NAME,
// 	ip.item_id,
// 	p.NAME,
// 	p.sku,
// 	p.pic_url,
// 	ip.shop_id,
// 	si.shop_name,
// 	ip.fn_sku,
// 	lf.fnsku;`,stock_id);


let stock_id = args.wareHouse;
lib.dbQueryJsonArray(`SELECT
	MD5(CONCAT(ip.stock_id,ip.item_id,p.name,p.sku,p.pic_url,ip.shop_id,si.shop_name,ip.fn_sku,availble_num,ip.defective_quantity)) id,
	ip.stock_id stockId,
	null wName,
	ip.item_id itemId,
	p.name pName,
	p.sku,
	p.pic_url picUrl,
	ip.shop_id shopId,
	si.shop_name sName,
	ip.fn_sku fnSku,
	lf.fnsku fnskuName,
	 ip.availble_num availbleNum,
	 ip.defective_quantity defectiveQuantity 
FROM
	inventory ip 
	LEFT JOIN product p ON p.id = ip.item_id
	LEFT JOIN shop_info si ON si.id = ip.shop_id
	LEFT JOIN listing_father lf ON lf.id = ip.fn_sku 
WHERE
	ip.stock_id = ?
	AND ip.del_flag = 0;`,stock_id);
